// pages/recharge/recharge.js
var app = getApp();
var req = require("../../utils/req.js");
var url = require("../../utils/url.js");
Page({

  /**
   * 页面的初始数据
   */
  data: {
    orderNumber: '',
    money: '',
    createTime: ''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(e) {
    console.log(e)
    this.setData({
      orderNumber: e.orderNumber,
      money: e.money,
      createTime: e.createTime
    })
  },
  rechargeMoney: function() {
    const data = {
      orderNumber: this.data.orderNumber
    }
    req.userRequest("请稍等", 'POST',url.pay['payRecharge'], data, function back(res) {
      wx.requestPayment({
        timeStamp: res.data.timeStamp,
        nonceStr: res.data.nonceStr,
        package: res.data.packageValue,
        signType: res.data.signType,
        paySign: res.data.paySign,
        success(res) {
          app.globalData.isNewUserInfo = true;
          wx.showLoading({
            title: '请稍等',
          })
          setTimeout(function(){
            wx.hideLoading();
            wx.navigateTo({
              url: '/pages/mine/mine',
            })
          },1500);
        },
      })
    })
  }
})